﻿using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

namespace Iot.Models
{
    public enum SwitchDeviceStatus
    {
        On = 1,
        Off = 0,
        Refresh = 2,
        None = -1
    }

    public class SwitchDevice
    {
        public string? SNID { get; set; }
        public string? DeviceMAC { get; set; }
        public string? Name { get; set; }
        public int GPIO { get; set; }


        /// <summary>
        /// 执行计划，定义：(时间:HHmmss,开关:0|时间:HHmmss,开关:1|)
        /// </summary>
        public string? Plans { get; set; }
        
        public SwitchDeviceStatus Status { get; set; } = SwitchDeviceStatus.None;

        [NotMapped]
        public string ControlStatus
        {
            get
            {
                return ((int)Status).ToString();
            }
        }

        [NotMapped]
        public string StatusString
        {
            get
            {
                switch (Status)
                {
                    case SwitchDeviceStatus.On:
                        return "已打开";
                    case SwitchDeviceStatus.Off:
                        return "已关闭";
                    case SwitchDeviceStatus.Refresh:
                        return "刷新";
                    default:
                        return "未知";
                }
            }
        }
    }
}
